$("#app_name").text("");
$("#app_mobile").text(APP.app_mobile);
function show_info(pay_price,score){
	var info="赠送0";
	if(score<0){
		info="赠送"+score;
	}
	if(score>0){
		info="抵扣"+score;
	}
		var html='</br><div class="sy_fukbt">'+
			'<span class="iconfont icon-chenggong"></span>'+
			'<span>收款<em>¥'+pay_price+'</em>元,鼓励金'+info+'</span>'+
		'</div>';
	layer.open({
		title: '收款通知',
		shadeClose: true,
		shade: 0.8,
		btn:false,
		area: ['380px', '300px'],
		content: html
	});
}
function set_keyup(type) {
	$("#mem_no").focus();
	document.onkeydown = function(e) {
		//捕捉回车事件
		var ev = (typeof event != 'undefined') ? window.event : e;
		if(ev.keyCode == 13) {
			if(e.srcElement.id == "mem_no") {
				$("#mem_card").focus();
			}
			if(e.srcElement.id == "mem_card") {
				var mem_card = $("#mem_card").val().trim();
				if(mem_card == "") {
					alert("请扫描会员付款码");
					$("#mem_card").focus();
				} else {
					$.ajax({
						url: APP.api_url + "Sy/zhu_pay",
						data: {
							oid: $("#oid").val(),
							mem_no: $("#mem_no").val(),
							mem_card: $("#mem_card").val()
						},
						success: function(data) {
							if(data.code != 200) {
								alert(data.msg);
							} else {
								wanchen(type);
								show_info(data['pay_price'], data['agent_score']);
							}
						}
					})

				}
			}
		}
	}
}

function getValue(name) {
	var member = JSON.parse(localStorage.getItem('member'));
	if(member){
		return member[name];
	}
	return "";
}
function keyup(obj) {
	obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
	obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
	obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
	obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
}
function exit() {
		var con = layer.confirm('确认退出系统?', function(index) {
			localStorage.clear();
			layer.close(con);
			window.location = "login.html";
		});
}
function set_info(){
		$("#sname").text(getValue("chain_name"));
		$("#user").text(getValue("name"));
		$("#toux").attr("src",getValue("logo")?getValue("logo"):'img/member.jpg');
		
}
function print_order(order_id){
		$.ajax({
			url: APP.api_url + "Sy/prt",
			data: {
				order_id: order_id
			},
			success: function(data) {
				
				
			}
		})
	
}
function print_order2(log_id){
		$.ajax({
			url: APP.api_url + "Sy/prt2",
			data: {
				log_id: log_id
			},
			success: function(data) {
								
			}
		})	
}
function print_item(order_id){
		$.ajax({
			url: APP.api_url + "Sy/prt_item",
			data: {
				order_id: order_id
			},
			success: function(data) {
								
			}
		})	
}
function wanchen(type){
	layer.closeAll();
	if(type==1){
		$("#price").val('');
	}else if(type==2){
		cart={};
		$("#list").html('');
		$("#total").text(0);
	}else if(type==3){
		clear_cart();
	}else if(type==4){
		pay_ok();
	}
}
function clear_cart(){
	$('.sy_proxlist').html('');
	$('#nums').text(0);
	$("#totals").text(0.00);
	cart={};
}
